<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>TodoList</title>
  <script src="https://unpkg.com/vue"></script>
</head>

<body>
  <div id="root"></div>
  <script>
    Vue.createApp({
      template: `<div>
        <input v-model="value"/>
        <button @click="add" >增加</button>
        <ul>
          <li v-for="(item,index) in list" :key="index">{{item}}</li>
        </ul>
        `,
      data() {
        return {
          list: ['任务1', '任务2', '任务3', '任务4'],
          value: ''
        }
      },
      methods: {
        add() {
          this.list.push(this.value);
          this.value = '';
        }
      }
    }).mount('#root');
  </script>
</body>

</html>